// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_MST_CUSTOMER_CONTACT
// * CreateDate    : 2011/9/27 13:27:06
// * Creater       : CodeSmith
// * LastChangeDate: 2011/9/27 13:27:06
// * LastChanger   : 2011/9/27 13:27:06
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Mst
{
/// <summary>
    /// MstCustomerContact
    /// </summary>
    public partial class MstCustomerContactBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objMstCustomerContactEntity">Entity</param>
        /// <returns>Entity</returns>
        public static MstCustomerContactEntity GetMstCustomerContact(MstCustomerContactEntity objMstCustomerContactEntity)
        {
            return DataAccess.SelectSingle<MstCustomerContactEntity>(objMstCustomerContactEntity);
        }
        public static MstCustomerContactEntity GetById(string contactId)
        {
            if (string.IsNullOrEmpty(contactId))
            {
                return null;
            }
            MstCustomerContactEntity entity = new MstCustomerContactEntity();
            entity.ContactId = contactId;
            return DataAccess.SelectSingle<MstCustomerContactEntity>(entity);
        }
        public static MstCustomerContactEntity GetByCustomer(string customerId, string contactLevel)
        {
            string sql = "SELECT * FROM MST_CUSTOMER_CONTACT WHERE Customer_ID = '" + customerId + "'";
            if (string.IsNullOrEmpty(contactLevel) == false)
            {
                sql += " AND CONTACT_LEVEL = '" + contactLevel + "'";
            }
            List<MstCustomerContactEntity> list = DataAccess.Select<MstCustomerContactEntity>(sql);
            if (list != null && list.Count > 0)
            {
                return list[0];
            }
            return null;
        }
        public static List<MstCustomerContactEntity> GetByCustomerId(string customerId)
        {
            if (string.IsNullOrEmpty(customerId))
            {
                return null;
            }
            MstCustomerContactEntity entity = new MstCustomerContactEntity();
            entity.CustomerId = customerId;
            return DataAccess.Select<MstCustomerContactEntity>(entity);
        }
        public static DataSet GetDataSetByCustomerId(string customerId)
        {
            string sql = "SELECT * FROM MST_CUSTOMER_CONTACT WHERE CUSTOMER_ID = '" + customerId + "'";
            return DataAccess.SelectDataSet(sql);
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objMstCustomerContactEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertMstCustomerContact(MstCustomerContactEntity objMstCustomerContactEntity)
        {
            return DataAccess.Insert(objMstCustomerContactEntity);
        }

        public static bool InsertMstCustomerContact(List<MstCustomerContactEntity> objMstCustomerContactEntityList)
        {
            return DataAccess.Insert(objMstCustomerContactEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objMstCustomerContactEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateMstCustomerContact(MstCustomerContactEntity objMstCustomerContactEntity)
        {
            return DataAccess.Update(objMstCustomerContactEntity);
        }

        public static bool UpdateMstCustomerContact(List<MstCustomerContactEntity> objMstCustomerContactEntityList)
        {
            return DataAccess.Update<MstCustomerContactEntity>(objMstCustomerContactEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objMstCustomerContactEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteMstCustomerContact(MstCustomerContactEntity objMstCustomerContactEntity)
        {
            return DataAccess.Delete(objMstCustomerContactEntity);
        }

        public static bool DeleteMstCustomerContact(List<MstCustomerContactEntity> objMstCustomerContactEntityList)
        {
            return DataAccess.Delete<MstCustomerContactEntity>(objMstCustomerContactEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetMstCustomerContactAll()
        {
            return DataAccess.SelectAllDataSet<MstCustomerContactEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<MstCustomerContactEntity> GetMstCustomerContactAllList()
        {
            return DataAccess.SelectAll<MstCustomerContactEntity>();
        }
        #endregion
	}
	
	
}	

